package com.woniuxy.controller;

import com.woniuxy.entity.QuestionInventory;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.QuestionInventoryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: TODO
 * @Author: HeMinghong
 * @CreateTime: 2022-06-01  16:12
 * @Version: 1.0
 */
@RestController
@CrossOrigin
@RequestMapping("/examQuestions")

public class InventoryController {
    @Autowired
    QuestionInventoryService questionInventoryService;

    @Autowired
    public InventoryController(QuestionInventoryService questionInventoryService) {
        this.questionInventoryService = questionInventoryService;
    }

    /**
     * @description:查询所有题库分类
     * @author: HeMinghong
     * @date: 2022/5/31 16:42
     * @param: []
     * @return: com.woniuxy.entity.ResponseEntity
     **/

    @RequestMapping("/findAll")
    public ResponseEntity findAll(){
        return questionInventoryService.findAll();
    }
    /**
     * @description:删除题库
     * @author: HeMinghong
     * @date: 2022/5/31 16:47
     * @param: [questionsInventory]
     * @return: com.woniuxy.entity.ResponseEntity
     **/
    @RequestMapping("/deleteOne")
    public ResponseEntity deleteOne(@RequestBody QuestionInventory questionInventory) {
        return questionInventoryService.deleteOne(questionInventory);
    }

    /**
     * @description:添加题库
     * @author: HeMinghong
     * @date: 2022/5/31 16:51
     * @param: [questionsInventory]
     * @return: com.woniuxy.entity.ResponseEntity
     **/
    @RequestMapping("/addOne")
    public ResponseEntity addOne(@RequestBody QuestionInventory questionInventory){
        return questionInventoryService.addOne(questionInventory);
    }

    @RequestMapping("/updateOne")
    public ResponseEntity updateOne(@RequestBody QuestionInventory questionInventory){
        return questionInventoryService.updateOne(questionInventory);
    }

    @RequestMapping("ilist")
    public ResponseEntity findInventories(){
        return new ResponseEntity(questionInventoryService.findInventories());
    }

    @RequestMapping("iList")
    public ResponseEntity findAllSubjects(){
        return new ResponseEntity(questionInventoryService.findAllSubjects());
    }

    @RequestMapping("iList2")
    public ResponseEntity findAllSubjects2(){
        return new ResponseEntity(questionInventoryService.findAllSubjects2());
    }

    @RequestMapping("findById")
    public ResponseEntity findById(Integer id){
        return questionInventoryService.findById(id);
    }

    @RequestMapping("/findBySubject")
    public QuestionInventory findBySubject(@RequestBody String subject){
        return questionInventoryService.findBySubject(subject);
    }

    @RequestMapping("/findAllSonSubjectById")
    public List<QuestionInventory> findAllSonSubjectById(@RequestBody Integer id){
        return questionInventoryService.findAllSonSubjectById(id);
    }


}
